package com.sunny.ynhz.ui.index;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;


import com.sunny.ynhz.R;
import com.sunny.ynhz.adapter.IndicatorAdapter;
import com.sunny.ynhz.ui.view.IndicatorViewPager;

import java.util.ArrayList;

/**
 * Created by tangyunfei on 2017/8/31.
 */

public class UserFragment extends Fragment {
    private View rootView;

    private IndicatorViewPager indicatorViewPager;
    private ViewPager mViewPager;
    private ArrayList<Fragment> list;
    private String[] cateData = new String[]{"会话", "通讯录", "工作组"};
    private TextView kefu;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        rootView = inflater.inflate(R.layout.fragment_user, container, false);
        initView();
        return rootView;
    }

    private void initView() {
        list = new ArrayList<>();
        list.add(new ChatFragment());
        list.add(new ContactsFragment());
        list.add(new GroupFragment());
        mViewPager = (ViewPager) rootView.findViewById(R.id.id_viewpager);
        IndicatorAdapter indicatorAdapter = new IndicatorAdapter(getActivity().getSupportFragmentManager(), list);
       mViewPager.setOffscreenPageLimit(3);
        mViewPager.setAdapter(indicatorAdapter);
        indicatorViewPager = rootView.findViewById(R.id.indicator);
        indicatorViewPager.setTabItems(cateData);
        indicatorViewPager.setViewPager(mViewPager, 0);
//        rootView.findViewById(R.id.img_search).setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                Intent intent = new Intent(getActivity(), LookForMsgActivity.class);
//                startActivity(intent);
//            }
//        });


    }
}
